package com.esri.android.map.popup;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.esri.android.map.popup.ArcGISAttributesAdapter;

/* loaded from: classes.dex */
public class ArcGISAbstractMediaView extends LinearLayout {
    protected static final int COLUMN_WIDTH = 150;
    protected static final int VERTICAL_SPACING = 5;
    Popup a;
    protected int mAdjustedColumnWidth;
    protected ExpandableHeightGridView mGrid;
    protected TextView mHeader;
    protected int mNumberOfColumns;
    protected View mSeparator;

    public ArcGISAbstractMediaView(Context context, Popup popup, String str) {
        super(context);
        setOrientation(1);
        this.a = popup;
        ArcGISPopupStyle arcGISPopupStyle = (ArcGISPopupStyle) popup.getLayout().getStyle();
        ArcGISAttributesAdapter.FieldLabelView fieldLabelView = new ArcGISAttributesAdapter.FieldLabelView(getContext(), str, arcGISPopupStyle);
        this.mHeader = fieldLabelView;
        addView(fieldLabelView);
        if (arcGISPopupStyle.getCustomFieldSeparator() != null) {
            this.mSeparator = arcGISPopupStyle.getCustomFieldSeparator();
        } else {
            this.mSeparator = new ArcGISAttributesAdapter.SeparatorView(getContext(), arcGISPopupStyle);
        }
        addView(this.mSeparator);
        ExpandableHeightGridView expandableHeightGridView = new ExpandableHeightGridView(getContext());
        this.mGrid = expandableHeightGridView;
        expandableHeightGridView.setPadding(0, 30, 0, 0);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
        layoutParams.gravity = 17;
        this.mGrid.setLayoutParams(layoutParams);
        this.mGrid.setGravity(17);
        this.mGrid.setVerticalSpacing(5);
        this.mGrid.setHorizontalSpacing(5);
        this.mGrid.setStretchMode(2);
        this.mGrid.setNumColumns(-1);
        this.mGrid.setClipToPadding(false);
        LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(-1, -1);
        layoutParams2.gravity = 17;
        addView(this.mGrid, layoutParams2);
    }

    /* loaded from: classes.dex */
    public class ExpandableHeightGridView extends GridView {
        public ExpandableHeightGridView(Context context) {
            super(context);
        }

        public ExpandableHeightGridView(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
        }

        public ExpandableHeightGridView(Context context, AttributeSet attributeSet, int i) {
            super(context, attributeSet, i);
        }

        @Override // android.widget.GridView, android.widget.AbsListView, android.view.View
        public void onMeasure(int i, int i2) {
            super.onMeasure(i, View.MeasureSpec.makeMeasureSpec(536870911, Integer.MIN_VALUE));
            ArcGISAbstractMediaView.this.mAdjustedColumnWidth = PopupUtil.convertDpInPixels(getContext(), 150);
            ArcGISAbstractMediaView.this.mNumberOfColumns = getMeasuredWidth() / ArcGISAbstractMediaView.this.mAdjustedColumnWidth;
            ArcGISAbstractMediaView.this.mAdjustedColumnWidth += (getMeasuredWidth() - ((ArcGISAbstractMediaView.this.mAdjustedColumnWidth * ArcGISAbstractMediaView.this.mNumberOfColumns) + ((ArcGISAbstractMediaView.this.mNumberOfColumns - 1) * 5))) / ArcGISAbstractMediaView.this.mNumberOfColumns;
            ArcGISAbstractMediaView.this.mGrid.setColumnWidth(ArcGISAbstractMediaView.this.mAdjustedColumnWidth);
            getLayoutParams().height = getMeasuredHeight();
        }
    }
}
